Skip to content

move setup banner after --json early return - #128

Merged
yourconscience merged 1 commit into
mainfrom
json-banner-fix
Jul 19, 2026
Merged

move setup banner after --json early return#128
yourconscience merged 1 commit into
mainfrom
json-banner-fix

Conversation

@yourconscience

@yourconscience yourconscience commented Jul 19, 2026

Copy link
Copy Markdown
Owner

The setup banner was printed to stdout before the --json early return, so dotagents setup --json output was not parseable JSON. Follow-up to #127 (this fix was on the branch but the PR merged before it landed). Part of #126.

Summary by Sourcery

Bug Fixes:

  • Prevent non-JSON banner output from being printed before --json mode so the command output remains parseable JSON.

@sourcery-ai

sourcery-ai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR adjusts when the setup banner is printed so that dotagents setup --json produces valid JSON by moving the banner output after the JSON early-return path.

Sequence diagram for dotagents setup JSON early return and banner printing

sequenceDiagram
  actor User
  participant CLI as dotagents_setup
  participant Streams
  participant Encoder

  User->>CLI: runSetup(opts)
  CLI->>Streams: setupStreams(opts)
  CLI->>CLI: loadSetupConfig(configPath, home)
  CLI->>CLI: detectLlmConfig(cfg, home)
  CLI->>CLI: detectRepo(detected)
  CLI->>Encoder: enc.Encode(detection)
  alt opts.json
    Encoder-->>User: JSON detection
    note over CLI,Encoder: runSetup returns before banner
  else no json flag
    CLI->>Streams: Fprintln(out, dotagents setup)
    CLI->>Streams: Fprintf(out, config root: repoRoot)
    CLI->>CLI: scanNativeImports(cfg, detected, repoRoot, home)
  end
Loading

File-Level Changes

Change Details Files
Ensure dotagents setup --json outputs parseable JSON by moving the setup banner printing until after the JSON early return.
  • Removed initial banner and config root prints before configuration loading and detection logic.
  • Added banner and config root prints after the JSON encoding early-return block so they are only emitted in non-JSON runs.
cmd/dotagents/setup.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider adding a brief comment near the banner print explaining that it must occur after the --json early return so future refactors don’t accidentally break JSON output again.
  • If dotagents setup output is expected to be machine-consumed in other contexts, you might want to gate the banner on an explicit interactive/tty check instead of only the JSON flag to avoid mixing human-readable banners with structured output.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider adding a brief comment near the banner print explaining that it must occur after the `--json` early return so future refactors don’t accidentally break JSON output again.
- If `dotagents setup` output is expected to be machine-consumed in other contexts, you might want to gate the banner on an explicit interactive/tty check instead of only the JSON flag to avoid mixing human-readable banners with structured output.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@yourconscience
yourconscience merged commit 0d61755 into main Jul 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant